<?php
namespace app\home\controller\user;

use app\BaseController;

use app\common\model\TouziProductOrder;
use app\common\model\User as models;

use app\common\traites\PublicCrudTrait;

use think\exception\ValidateException;
use think\facade\Db;
use hg\apidoc\annotation as Apidoc;

/**
 *
 * @Apidoc\Title("个人中心")
 * */
class Product extends BaseController
{
    protected $model;
    use PublicCrudTrait;

    public function initialize()
    {
        $this->model = new models();
        parent::initialize(); // TODO: Change the autogenerated stub
    }
    /**
     * @Apidoc\Title("(分红)产品购买记录")
     * @Apidoc\Method("POST")
     * @Apidoc\Param("page", type="string",require=true, desc="页面")
     * @Apidoc\Param("limit", type="string",require=true, desc="分页限制")
     * @Apidoc\Param("start", type="string",require=true, desc="开始时间 可以不写")
     * @Apidoc\Param("end", type="string",require=true, desc="结束时间 可以不写")
     * @Apidoc\Returned("data", type="array", desc="返回数据")
     */
    public function product_buy_records(){
        $uid= session('home_user.id');
        //过滤数据
        // $postField = 'page,limit,start,end';
        // $post   = $this->request->only(explode(',', $postField), 'post', null);

        $page = $this->request->post('page', 1);//当前页
        $limit = $this->request->post('limit', 10);//每页显示数量
        $start = $this->request->post('start'); // 搜索开始时间
        $end = $this->request->post('end'); // 搜索结束时间
        $date = [];
        if(!empty($start) && !empty($end)){
            $date['start'] = $start;
            $date['end'] = $end;
        }

        $map = [];
        $map['a.user_id']= $uid;
        $res=(new TouziProductOrder())->page_list_home($map,$limit,$page,$date);
        return show($res);
    }
    /**
     * @Apidoc\Title("(分红)产品购买记录")
     * @Apidoc\Method("POST")
     * @Apidoc\Param("page", type="string",require=true, desc="页面")
     * @Apidoc\Param("limit", type="string",require=true, desc="分页限制")
     * @Apidoc\Param("start", type="string",require=true, desc="开始时间 可以不写")
     * @Apidoc\Param("end", type="string",require=true, desc="结束时间 可以不写")
     * @Apidoc\Returned("data", type="array", desc="返回数据")
     */
    public function product_buy_records_gongfu(){
        $uid= session('home_user.id');
        //过滤数据
        // $postField = 'page,limit,start,end';
        // $post   = $this->request->only(explode(',', $postField), 'post', null);

        $page = $this->request->post('page', 1);//当前页
        $limit = $this->request->post('limit', 10);//每页显示数量
        $start = $this->request->post('start'); // 搜索开始时间
        $end = $this->request->post('end'); // 搜索结束时间
        $date = [];
        if(!empty($start) && !empty($end)){
            $date['start'] = $start;
            $date['end'] = $end;
        }

        $map = [];
        $map['a.user_id']= $uid;
        $map['a.class_type_id']= '3';
        $res=(new TouziProductOrder())->page_list_home($map,$limit,$page,$date);
        return show($res);
    }

    /**
     * @Apidoc\Title("(分红)产品收益发放记录")
     * @Apidoc\Method("POST")
     * @Apidoc\Param("page", type="string",require=true, desc="页面")
     * @Apidoc\Param("limit", type="string",require=true, desc="分页限制")
     * @Apidoc\Param("start", type="string",require=true, desc="开始时间 可以不写")
     * @Apidoc\Param("end", type="string",require=true, desc="结束时间 可以不写")
     * @Apidoc\Returned("data", type="array", desc="返回数据")
     */
    public function product_income_records(){
        $uid= session('home_user.id');
        //过滤数据
        // $postField = 'page,limit,start,end';
        // $post   = $this->request->only(explode(',', $postField), 'post', null);

        $page = $this->request->post('page', 1);//当前页
        $limit = $this->request->post('limit', 10);//每页显示数量
        $start = $this->request->post('start'); // 搜索开始时间
        $end = $this->request->post('end'); // 搜索结束时间
        $date = [];
        if(!empty($start) && !empty($end)){
            $date['start'] = $start;
            $date['end'] = $end;
        }

        $map = [];
        $map['user_id']= $uid;
        $res=(new TouziGainSendLog())->page_list($map,$limit,$page,$date);
        return show($res);
    }
// 类结束了
}
